import { Tile as TileLayer } from 'ol/layer'
import { XYZ } from 'ol/source'
import gcj02Mecator from '@/utils/gcj02Mecator.js'

// 加载高德底图
// gcj02Mecator 用来解决高德地图坐标偏移问题
// 使用了gcj02Mecator 坐标要通过fromLonLat转一下
export function useGaoTileLayer() {
  return [
    new TileLayer({
      visible: true,
      source: new XYZ({
        projection: gcj02Mecator,
        url: 'http://webrd0{1-4}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=2&scale=1&style=8',
        // url: 'http://webrd0{1-4}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=7',
        // url: 'http://webst0{1-4}.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=2&scale=1&style=6',
        crossOrigin: 'anonymous'
      })
    })
  ]
}